package com.hwl.demo5.service.impl;

import com.hwl.demo3.component.CashNormal;
import com.hwl.demo3.component.CashRebate;
import com.hwl.demo3.component.CashReturn;
import com.hwl.demo3.service.ISale;
import com.hwl.demo5.service.IShopFactory;

/**
 * 先满减再打折类
 *
 * @author sentry
 * @since 2023-03-18
 */
public class CashReturnRebateFactory implements IShopFactory {

    private final double moneyRebate;
    private final double moneyCondition;
    private final double moneyReturn;

    public CashReturnRebateFactory(double moneyRebate, double moneyCondition, double moneyReturn) {
        this.moneyRebate = moneyRebate;
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public ISale createSalesMode() {
        CashNormal cn2 = new CashNormal();
        CashRebate cr3 = new CashRebate(moneyRebate);
        CashReturn cr4 = new CashReturn(moneyCondition, moneyReturn);

        cr3.decorate(cn2);
        cr4.decorate(cr3);
        return cr4;
    }
}
